Skip to contentSkip to conversation

Change in openvpn[master]: test_user_pass: Check fatal errors for empty username/password

Openvpn-devel In review flichtenheld (Code Review) 2 participants 18 messages Dec 8, 2023 – Oct 11, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1702052980000.Icabc8acf75638c86c8c395e9ffecba7a7226cd97@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/474?usp=email

to review the following change.

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

test_user_pass: Check fatal errors for empty username/password

Required a fix to mock_msg to make tests of M_FATAL possible at all.
This also tests some cases which arguably should throw a fatal error but do not.

Change-Id Icabc8acf75638c86c8c395e9ffecba7a7226cd97

---
A tests/unit_tests/openvpn/input/appears_empty.txt A tests/unit_tests/openvpn/input/empty.txt M tests/unit_tests/openvpn/mock_msg.c
M tests/unit_tests/openvpn/test_user_pass.c

4 files changed, 68 insertions(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/74/474/1

tests/unit_tests/openvpn/input/appears_empty.txt new file +3 -0
new file mode 100644
index 0000000..ffb749a
@@ -0,0 +1,3 @@
+
+
+(contains \t\n\t\n)
tests/unit_tests/openvpn/input/empty.txt new file +0 -0
new file mode 100644
index 0000000..e69de29
tests/unit_tests/openvpn/mock_msg.c +4 -2
index d74efaa..2fcad9d 100644
@@ -38,7 +38,6 @@
 #include "error.h"
 
 unsigned int x_debug_level = 0; /* Default to (almost) no debugging output */
-bool fatal_error_triggered = false;
 
 void
 mock_set_debug_level(int level)
@@ -58,11 +57,14 @@
 {
     if (flags & M_FATAL)
     {
-        fatal_error_triggered = true;
         printf("FATAL ERROR:");
     }
     vprintf(format, arglist);
     printf("\n");
+    if (flags & M_FATAL)
+    {
+        mock_assert(false, "FATAL ERROR", __FILE__, __LINE__);
+    }
 }
 
 void
tests/unit_tests/openvpn/test_user_pass.c +61 -0

97 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/474?usp=email

to look at the new patch set (#2).

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

test_user_pass: Check fatal errors for empty username/password

Required a fix to mock_msg to make tests of M_FATAL possible at all.
This also tests some cases which arguably should throw a fatal error but do not.

v2:
- Suppress LeakSanitizer errors for fatal error tests. Due to aborting the function, the memory will not be cleaned up, but that is expected.

Change-Id Icabc8acf75638c86c8c395e9ffecba7a7226cd97

---
M .github/workflows/build.yaml
M CMakeLists.txt
M tests/unit_tests/openvpn/Makefile.am
A tests/unit_tests/openvpn/input/appears_empty.txt A tests/unit_tests/openvpn/input/empty.txt A tests/unit_tests/openvpn/input/leak_suppr.txt M tests/unit_tests/openvpn/mock_msg.c
M tests/unit_tests/openvpn/test_user_pass.c

8 files changed, 100 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/74/474/2

.github/workflows/build.yaml +1 -0
index d7cc01c..784a844 100644
@@ -283,6 +283,7 @@
           configurePreset: win-${{ matrix.arch }}-release
           buildPreset: win-${{ matrix.arch }}-release
           testPreset: win-${{ matrix.arch }}-release
+          testPresetAdditionalArgs: "['--output-on-failure']"
 
       - uses: actions/[email protected]...
         with:
CMakeLists.txt +2 -1
index 3f96354..142bde4 100644
@@ -621,8 +621,9 @@
         if (NOT ${test_name} STREQUAL "test_networking")
             add_test(${test_name} ${test_name})
             # for compat with autotools make check
+            set(_UT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn)
             set_tests_properties(${test_name} PROPERTIES
-                ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn")
+                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR};LSAN_OPTIONS=suppressions=${_UT_SOURCE_DIR}/input/leak_suppr.txt")
         endif ()
         add_executable(${test_name}
             tests/unit_tests/openvpn/${test_name}.c
tests/unit_tests/openvpn/Makefile.am +2 -0
index 6199b4a..ac85aca 100644
@@ -2,6 +2,8 @@
 
 EXTRA_DIST = input
 
+export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt
+
 test_binaries=
 
 if HAVE_LD_WRAP_SUPPORT
tests/unit_tests/openvpn/input/appears_empty.txt new file +3 -0
new file mode 100644
index 0000000..ffb749a
@@ -0,0 +1,3 @@
+
+
+(contains \t\n\t\n)
tests/unit_tests/openvpn/input/empty.txt new file +0 -0
new file mode 100644
index 0000000..e69de29
tests/unit_tests/openvpn/input/leak_suppr.txt new file +1 -0
new file mode 100644
index 0000000..72ebfe0
@@ -0,0 +1 @@
+leak:_assertions$
tests/unit_tests/openvpn/mock_msg.c +4 -2
index d74efaa..2fcad9d 100644
@@ -38,7 +38,6 @@
 #include "error.h"
 
 unsigned int x_debug_level = 0; /* Default to (almost) no debugging output */
-bool fatal_error_triggered = false;
 
 void
 mock_set_debug_level(int level)
@@ -58,11 +57,14 @@
 {
     if (flags & M_FATAL)
     {
-        fatal_error_triggered = true;
         printf("FATAL ERROR:");
     }
     vprintf(format, arglist);
     printf("\n");
+    if (flags & M_FATAL)
+    {
+        mock_assert(false, "FATAL ERROR", __FILE__, __LINE__);
+    }
 }
 
 void
tests/unit_tests/openvpn/test_user_pass.c +87 -0

123 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newpatchset

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/474?usp=email )

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

Patch Set 2: Code-Review-1

(2 comments)

Patchset:

PS2:
I tried to replicate the leak that is being supressed (with blanking the content of that .txt file) but cannot trigger it at least on macOS. It would be also good to actually have a comment in the unit where the supressed leak is happening.

File tests/unit_tests/openvpn/input/leak_suppr.txt:

http://gerrit.openvpn.net/c/openvpn/+/474/comment/cf59cf0c_68f7af73 :
PS2, Line 1: leak:_assertions$
This feels unecessarily broad. Especially since we are using it on every unit test that is being run and not only on the input unit tests.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 11 Dec 2023 14:58:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/474?usp=email )

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

Patch Set 2:

(1 comment)

File tests/unit_tests/openvpn/input/leak_suppr.txt:

http://gerrit.openvpn.net/c/openvpn/+/474/comment/ba78df38_3f4e21f0 :
PS2, Line 1: leak:_assertions$

Quoted 1 line

This feels unecessarily broad. […]

That was intentional. Having a common suffix for tests that can leak due to testing program aborts feels useful. Would you maybe prefer a different suffix? Like _leak?

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Mon, 11 Dec 2023 16:06:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]...>
Gerrit-MessageType: comment

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/474?usp=email

to look at the new patch set (#3).

The following approvals got outdated and were removed:
Code-Review-1 by plaisthos

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

test_user_pass: Check fatal errors for empty username/password

Required a fix to mock_msg to make tests of M_FATAL possible at all.
This also tests some cases which arguably should throw a fatal error but do not.

v2:
- Suppress LeakSanitizer errors for fatal error tests. Due to aborting the function, the memory will not be cleaned up, but that is expected.
v3:
- Disable assert tests with MSVC. Does not seem to catch the error correctly.
- Rebase on top of parallel-tests series to get AM_TESTS_ENVIRONMENT.

Change-Id Icabc8acf75638c86c8c395e9ffecba7a7226cd97

---
M CMakeLists.txt
M tests/unit_tests/openvpn/Makefile.am
A tests/unit_tests/openvpn/input/appears_empty.txt A tests/unit_tests/openvpn/input/empty.txt A tests/unit_tests/openvpn/input/leak_suppr.txt M tests/unit_tests/openvpn/mock_msg.c
M tests/unit_tests/openvpn/test_user_pass.c

7 files changed, 112 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/74/474/3

CMakeLists.txt +1 -1
index af891a5..bbbf683 100644
@@ -649,7 +649,7 @@
             # for compat with autotools make check
             set(_UT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn)
             set_tests_properties(${test_name} PROPERTIES
-                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR}")
+                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR};LSAN_OPTIONS=suppressions=${_UT_SOURCE_DIR}/input/leak_suppr.txt")
         endif ()
         add_executable(${test_name}
             tests/unit_tests/openvpn/${test_name}.c
tests/unit_tests/openvpn/Makefile.am +2 -0
index 342f428..5d95c7b 100644
@@ -4,6 +4,8 @@
 
 AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) Unit-Tests'
 
+AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt;
+
 test_binaries=
 
 if HAVE_LD_WRAP_SUPPORT
tests/unit_tests/openvpn/input/appears_empty.txt new file +3 -0
new file mode 100644
index 0000000..ffb749a
@@ -0,0 +1,3 @@
+
+
+(contains \t\n\t\n)
tests/unit_tests/openvpn/input/empty.txt new file +0 -0
new file mode 100644
index 0000000..e69de29
tests/unit_tests/openvpn/input/leak_suppr.txt new file +1 -0
new file mode 100644
index 0000000..72ebfe0
@@ -0,0 +1 @@
+leak:_assertions$
tests/unit_tests/openvpn/mock_msg.c +4 -2
index d74efaa..2fcad9d 100644
@@ -38,7 +38,6 @@
 #include "error.h"
 
 unsigned int x_debug_level = 0; /* Default to (almost) no debugging output */
-bool fatal_error_triggered = false;
 
 void
 mock_set_debug_level(int level)
@@ -58,11 +57,14 @@
 {
     if (flags & M_FATAL)
     {
-        fatal_error_triggered = true;
         printf("FATAL ERROR:");
     }
     vprintf(format, arglist);
     printf("\n");
+    if (flags & M_FATAL)
+    {
+        mock_assert(false, "FATAL ERROR", __FILE__, __LINE__);
+    }
 }
 
 void
tests/unit_tests/openvpn/test_user_pass.c +101 -0

139 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newpatchset

#6 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/474?usp=email )

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

Patch Set 6: Code-Review-1

(1 comment)

Patchset:

PS6:
This test has a bigger problem with the use of files in the source dir. In the github action run we archive the unit test binaries and run them without the source directory present. I am currently facing the same issue in my list test that read COPYRIGHT.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 19 Jan 2024 15:44:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#7 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/474?usp=email )

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

Patch Set 7:

(1 comment)

Patchset:

PS6:

Quoted 1 line

This test has a bigger problem with the use of files in the source dir. […]

That has nothing to do with this patch. This problem is introduced and solved in https://gerrit.openvpn.net/c/openvpn/+/468. Please discuss there.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 7
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Mon, 22 Jan 2024 13:15:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]...>
Gerrit-MessageType: comment

#8 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/474?usp=email

to look at the new patch set (#8).

The following approvals got outdated and were removed:
Code-Review-1 by plaisthos

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

test_user_pass: Check fatal errors for empty username/password

Required a fix to mock_msg to make tests of M_FATAL possible at all.
This also tests some cases which arguably should throw a fatal error but do not.

v2:
- Suppress LeakSanitizer errors for fatal error tests. Due to aborting the function, the memory will not be cleaned up, but that is expected.
v3:
- Disable assert tests with MSVC. Does not seem to catch the error correctly.
- Rebase on top of parallel-tests series to get AM_TESTS_ENVIRONMENT.
v8:
- Update srcdir handling according to master.

Change-Id Icabc8acf75638c86c8c395e9ffecba7a7226cd97

---
M CMakeLists.txt
M tests/unit_tests/openvpn/Makefile.am
A tests/unit_tests/openvpn/input/appears_empty.txt A tests/unit_tests/openvpn/input/empty.txt A tests/unit_tests/openvpn/input/leak_suppr.txt M tests/unit_tests/openvpn/mock_msg.c
M tests/unit_tests/openvpn/test_user_pass.c

7 files changed, 110 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/74/474/8

CMakeLists.txt +1 -1
index fdd2b01..a96733e 100644
@@ -666,7 +666,7 @@
             # for compat with autotools make check
             set(_UT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn)
             set_tests_properties(${test_name} PROPERTIES
-                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR}")
+                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR};LSAN_OPTIONS=suppressions=${_UT_SOURCE_DIR}/input/leak_suppr.txt")
         endif ()
         add_executable(${test_name}
             tests/unit_tests/openvpn/${test_name}.c
tests/unit_tests/openvpn/Makefile.am +2 -0
index 88a694d..7b0a086 100644
@@ -4,6 +4,8 @@
 
 AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) Unit-Tests'
 
+AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt;
+
 test_binaries=
 
 if HAVE_LD_WRAP_SUPPORT
tests/unit_tests/openvpn/input/appears_empty.txt new file +3 -0
new file mode 100644
index 0000000..ffb749a
@@ -0,0 +1,3 @@
+
+
+(contains \t\n\t\n)
tests/unit_tests/openvpn/input/empty.txt new file +0 -0
new file mode 100644
index 0000000..e69de29
tests/unit_tests/openvpn/input/leak_suppr.txt new file +1 -0
new file mode 100644
index 0000000..72ebfe0
@@ -0,0 +1 @@
+leak:_assertions$
tests/unit_tests/openvpn/mock_msg.c +4 -2
index d74efaa..2fcad9d 100644
@@ -38,7 +38,6 @@
 #include "error.h"
 
 unsigned int x_debug_level = 0; /* Default to (almost) no debugging output */
-bool fatal_error_triggered = false;
 
 void
 mock_set_debug_level(int level)
@@ -58,11 +57,14 @@
 {
     if (flags & M_FATAL)
     {
-        fatal_error_triggered = true;
         printf("FATAL ERROR:");
     }
     vprintf(format, arglist);
     printf("\n");
+    if (flags & M_FATAL)
+    {
+        mock_assert(false, "FATAL ERROR", __FILE__, __LINE__);
+    }
 }
 
 void
tests/unit_tests/openvpn/test_user_pass.c +99 -0

137 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 8
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newpatchset

#9 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/474?usp=email

to look at the new patch set (#11).

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

test_user_pass: Check fatal errors for empty username/password

Required a fix to mock_msg to make tests of M_FATAL possible at all.
This also tests some cases which arguably should throw a fatal error but do not.

v2:
- Suppress LeakSanitizer errors for fatal error tests. Due to aborting the function, the memory will not be cleaned up, but that is expected.
v3:
- Disable assert tests with MSVC. Does not seem to catch the error correctly.
- Rebase on top of parallel-tests series to get AM_TESTS_ENVIRONMENT.
v8:
- Update srcdir handling according to master.
v10:
- Update mock_msg.c fatal handling to be compatible with NO_CMOCKA.

Change-Id Icabc8acf75638c86c8c395e9ffecba7a7226cd97

---
M CMakeLists.txt
M tests/unit_tests/openvpn/Makefile.am
A tests/unit_tests/openvpn/input/appears_empty.txt A tests/unit_tests/openvpn/input/empty.txt A tests/unit_tests/openvpn/input/leak_suppr.txt M tests/unit_tests/openvpn/mock_msg.c
M tests/unit_tests/openvpn/test_user_pass.c

7 files changed, 112 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/74/474/11

CMakeLists.txt +1 -1
index f8b37a9..e32c99c 100644
@@ -668,7 +668,7 @@
             # for compat with autotools make check
             set(_UT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn)
             set_tests_properties(${test_name} PROPERTIES
-                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR}")
+                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR};LSAN_OPTIONS=suppressions=${_UT_SOURCE_DIR}/input/leak_suppr.txt")
         endif ()
         add_executable(${test_name}
             tests/unit_tests/openvpn/${test_name}.c
tests/unit_tests/openvpn/Makefile.am +2 -0
index a4e6235..22dc075 100644
@@ -4,6 +4,8 @@
 
 AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) Unit-Tests'
 
+AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt;
+
 test_binaries=
 
 if HAVE_LD_WRAP_SUPPORT
tests/unit_tests/openvpn/input/appears_empty.txt new file +3 -0
new file mode 100644
index 0000000..ffb749a
@@ -0,0 +1,3 @@
+
+
+(contains \t\n\t\n)
tests/unit_tests/openvpn/input/empty.txt new file +0 -0
new file mode 100644
index 0000000..e69de29
tests/unit_tests/openvpn/input/leak_suppr.txt new file +1 -0
new file mode 100644
index 0000000..72ebfe0
@@ -0,0 +1 @@
+leak:_assertions$
tests/unit_tests/openvpn/mock_msg.c +6 -2
index a291f8f..098f56b 100644
@@ -39,7 +39,6 @@
 #include "error.h"
 
 unsigned int x_debug_level = 0; /* Default to (almost) no debugging output */
-bool fatal_error_triggered = false;
 
 void
 mock_set_debug_level(int level)
@@ -59,11 +58,16 @@
 {
     if (flags & M_FATAL)
     {
-        fatal_error_triggered = true;
         printf("FATAL ERROR:");
     }
     vprintf(format, arglist);
     printf("\n");
+#ifndef NO_CMOCKA
+    if (flags & M_FATAL)
+    {
+        mock_assert(false, "FATAL ERROR", __FILE__, __LINE__);
+    }
+#endif
 }
 
 void
tests/unit_tests/openvpn/test_user_pass.c +99 -0

137 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 11
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newpatchset

#10 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/474?usp=email

to look at the new patch set (#13).

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

test_user_pass: Check fatal errors for empty username/password

Required a fix to mock_msg to make tests of M_FATAL possible at all.
This also tests some cases which arguably should throw a fatal error but do not.

v2:
- Suppress LeakSanitizer errors for fatal error tests. Due to aborting the function, the memory will not be cleaned up, but that is expected.
v3:
- Disable assert tests with MSVC. Does not seem to catch the error correctly.
- Rebase on top of parallel-tests series to get AM_TESTS_ENVIRONMENT.
v8:
- Update srcdir handling according to master.
v10:
- Update mock_msg.c fatal handling to be compatible with NO_CMOCKA.

Change-Id Icabc8acf75638c86c8c395e9ffecba7a7226cd97

---
M CMakeLists.txt
M tests/unit_tests/openvpn/Makefile.am
A tests/unit_tests/openvpn/input/appears_empty.txt A tests/unit_tests/openvpn/input/empty.txt A tests/unit_tests/openvpn/input/leak_suppr.txt M tests/unit_tests/openvpn/mock_msg.c
M tests/unit_tests/openvpn/test_user_pass.c

7 files changed, 112 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/74/474/13

CMakeLists.txt +1 -1
index 9511bda..9e0b46e 100644
@@ -729,7 +729,7 @@
             add_test(${test_name} ${test_name})
             # for compat with autotools make check
             set_tests_properties(${test_name} PROPERTIES
-                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR}")
+                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR};LSAN_OPTIONS=suppressions=${_UT_SOURCE_DIR}/input/leak_suppr.txt")
         endif ()
         add_executable(${test_name}
             tests/unit_tests/openvpn/${test_name}.c
tests/unit_tests/openvpn/Makefile.am +2 -0
index 05c0ea5..50f4a11 100644
@@ -4,6 +4,8 @@
 
 AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) Unit-Tests'
 
+AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt;
+
 test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \
 	ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \
 	user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver
tests/unit_tests/openvpn/input/appears_empty.txt new file +3 -0
new file mode 100644
index 0000000..ffb749a
@@ -0,0 +1,3 @@
+
+
+(contains \t\n\t\n)
tests/unit_tests/openvpn/input/empty.txt new file +0 -0
new file mode 100644
index 0000000..e69de29
tests/unit_tests/openvpn/input/leak_suppr.txt new file +1 -0
new file mode 100644
index 0000000..72ebfe0
@@ -0,0 +1 @@
+leak:_assertions$
tests/unit_tests/openvpn/mock_msg.c +6 -2
index a2aa3f9..2cd1336 100644
@@ -41,7 +41,6 @@
 msglvl_t x_debug_level = 0; /* Default to (almost) no debugging output */
 msglvl_t print_x_debug_level = 0;
 
-bool fatal_error_triggered = false;
 
 char mock_msg_buf[MOCK_MSG_BUF];
 
@@ -75,7 +74,6 @@
 {
     if (flags & M_FATAL)
     {
-        fatal_error_triggered = true;
         printf("FATAL ERROR:");
     }
     CLEAR(mock_msg_buf);
@@ -86,6 +84,12 @@
         printf("%s", mock_msg_buf);
         printf("\n");
     }
+#ifndef NO_CMOCKA
+    if (flags & M_FATAL)
+    {
+        mock_assert(false, "FATAL ERROR", __FILE__, __LINE__);
+    }
+#endif
 }
 
 void
tests/unit_tests/openvpn/test_user_pass.c +99 -0

137 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 13
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#11 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/474?usp=email )

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

Patch Set 13: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 13
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 10 Oct 2025 21:11:37 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#12 lore raw

PATCH v13 1/1 test_user_pass: Check fatal errors for empty username/password

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

Required a fix to mock_msg to make tests of M_FATAL possible at all.
This also tests some cases which arguably should throw a fatal error but do not.

v2:
- Suppress LeakSanitizer errors for fatal error tests. Due to aborting the function, the memory will not be cleaned up, but that is expected.
v3:
- Disable assert tests with MSVC. Does not seem to catch the error correctly.
- Rebase on top of parallel-tests series to get AM_TESTS_ENVIRONMENT.
v8:
- Update srcdir handling according to master.
v10:
- Update mock_msg.c fatal handling to be compatible with NO_CMOCKA.

Change-Id Icabc8acf75638c86c8c395e9ffecba7a7226cd97

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/474
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/474
This mail reflects revision 13 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

CMakeLists.txt +1 -1
index 9511bda..9e0b46e 100644
@@ -729,7 +729,7 @@
             add_test(${test_name} ${test_name})
             # for compat with autotools make check
             set_tests_properties(${test_name} PROPERTIES
-                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR}")
+                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR};LSAN_OPTIONS=suppressions=${_UT_SOURCE_DIR}/input/leak_suppr.txt")
         endif ()
         add_executable(${test_name}
             tests/unit_tests/openvpn/${test_name}.c
tests/unit_tests/openvpn/Makefile.am +2 -0
index 05c0ea5..50f4a11 100644
@@ -4,6 +4,8 @@
 
 AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) Unit-Tests'
 
+AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt;
+
 test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \
 	ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \
 	user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver
tests/unit_tests/openvpn/input/appears_empty.txt new file +3 -0
new file mode 100644
index 0000000..ffb749a
@@ -0,0 +1,3 @@
+	
+	
+(contains \t\n\t\n)
tests/unit_tests/openvpn/input/empty.txt new file +0 -0
new file mode 100644
index 0000000..e69de29
tests/unit_tests/openvpn/input/leak_suppr.txt new file +1 -0
new file mode 100644
index 0000000..72ebfe0
@@ -0,0 +1 @@
+leak:_assertions$
tests/unit_tests/openvpn/mock_msg.c +6 -2
index a2aa3f9..2cd1336 100644
@@ -41,7 +41,6 @@
 msglvl_t x_debug_level = 0; /* Default to (almost) no debugging output */
 msglvl_t print_x_debug_level = 0;
 
-bool fatal_error_triggered = false;
 
 char mock_msg_buf[MOCK_MSG_BUF];
 
@@ -75,7 +74,6 @@
 {
     if (flags & M_FATAL)
     {
-        fatal_error_triggered = true;
         printf("FATAL ERROR:");
     }
     CLEAR(mock_msg_buf);
@@ -86,6 +84,12 @@
         printf("%s", mock_msg_buf);
         printf("\n");
     }
+#ifndef NO_CMOCKA
+    if (flags & M_FATAL)
+    {
+        mock_assert(false, "FATAL ERROR", __FILE__, __LINE__);
+    }
+#endif
 }
 
 void
tests/unit_tests/openvpn/test_user_pass.c +99 -0

137 lines not on this page · raw message

#13 lore raw

[Openvpn-devel] [PATCH applied] Re: test_user_pass: Check fatal errors for empty username/password

This needed a few rounds on my end - the patch adds a new file that consists of "CR+NL" line endings, and "git am --whitespace=fix" helpfully fixed that... pushing to GHA still worked(!), seems the test magic running this on a windows machine restored the line endings
- my own tests on FreeBSD and Linux failed. Applied with "=ignore", and magic!

============================================================================
Testsuite summary for OpenVPN 2.7_beta2 Unit-Tests
============================================================================
# TOTAL: 15
# PASS: 15

(it's not possible to run this test driver "just so" from the command line, though :( ).

Github action also still succeeds, BB all green, and the changes look good and tests for the user/password parsing are most welcome - we've had our share of bugs in this, so, more tests, less surprises.

Your patch has been applied to the master branch.

commit e7fdde7cb8d39a51a4a38b0d16f23a18d086cfe2

Author: Frank Lichtenheld
Date:   Fri Oct 10 23:11:47 2025 +0200
     test_user_pass: Check fatal errors for empty username/password

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/474
     Message-Id: <[email protected]...>
     URL: https://sourceforge.net/p/openvpn/mailman/message/59245149/
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#14 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/474?usp=email )

The change is no longer submittable: Code-Review is unsatisfied now.

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

Patch Set 13: Code-Review-2

(1 comment)

Patchset:

PS13:
While it passes BB and GHA checks(!), it fails for my local builds - both on Linux and FreeBSD.

Output is just

```
...
PASS: ssl_testdriver
FAIL: user_pass_testdriver
PASS: push_update_msg_testdriver
...
```

if I run the binary from hand (not sure if this is supposed to work, it works for all the other tests) it says

```
[email protected]... ~/t_server.git/tests/unit_tests/openvpn $ ./user_pass_testdriver
[==========] Running 10 test(s).
[ RUN      ] test_get_user_pass_defined
...
[ RUN      ] test_get_user_pass_authfile_file_assertions
[  ERROR   ] --- srcdir
[   LINE   ] --- test_common.h:63: error: Failure!
[  FAILED  ] test_get_user_pass_authfile_file_assertions
[==========] 10 test(s) run.
[  PASSED  ] 8 test(s).
[  FAILED  ] 2 test(s), listed below:
[  FAILED  ] test_get_user_pass_authfile_file
[  FAILED  ] test_get_user_pass_authfile_file_assertions

 2 FAILED TEST(S)
[ RUN      ] test_get_user_pass_authfile_file_assertions
[  ERROR   ] --- srcdir
[   LINE   ] --- test_common.h:63: error: Failure!
[  FAILED  ] test_get_user_pass_authfile_file_assertions
[==========] 10 test(s) run.
[  PASSED  ] 8 test(s).
[  FAILED  ] 2 test(s), listed below:
[  FAILED  ] test_get_user_pass_authfile_file
[  FAILED  ] test_get_user_pass_authfile_file_assertions

 2 FAILED TEST(S)
```

I first thought it's something with "in tree builds", but it also fails "out of tree" builds (only tested on FreeBSD). Maybe cmocka version? 1.1.8 on FreeBSD, 1.1.5-r1 on gentoo.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 13
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 10 Oct 2025 21:28:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#15 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/474?usp=email )

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

Patch Set 13: -Code-Review

(1 comment)

Patchset:

PS13:
ah, I think I know what happened. My "git am" does whitespace fixes, and it printed something on "whitespace errors fixed on apply" - will re-test tomorrow. Resetting to "0" for the time being.

Signature · 18 lines
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 13
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 10 Oct 2025 21:38:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
#16 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/474?usp=email )

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

Patch Set 13: Code-Review+2

(3 comments)

Patchset:

PS13:
git am --whitespace=fix messed up the CR+NL line endings in a way that "checkouts on windows" still worked and "checkouts on unixy systems" not. --whitespace=ignore fixed it.

PS13:

Quoted 1 line

While it passes BB and GHA checks(!), it fails for my local builds - both on Linux and FreeBSD. […]

Done

PS13:

Quoted 1 line

ah, I think I know what happened. […]

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 13
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Sat, 11 Oct 2025 09:59:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: cron2 <[email protected]...>

#17 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#14) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/474?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

test_user_pass: Check fatal errors for empty username/password

Required a fix to mock_msg to make tests of M_FATAL possible at all.
This also tests some cases which arguably should throw a fatal error but do not.

v2:
- Suppress LeakSanitizer errors for fatal error tests. Due to aborting the function, the memory will not be cleaned up, but that is expected.
v3:
- Disable assert tests with MSVC. Does not seem to catch the error correctly.
- Rebase on top of parallel-tests series to get AM_TESTS_ENVIRONMENT.
v8:
- Update srcdir handling according to master.
v10:
- Update mock_msg.c fatal handling to be compatible with NO_CMOCKA.

Change-Id Icabc8acf75638c86c8c395e9ffecba7a7226cd97

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/474
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59245149/

---
M CMakeLists.txt
M tests/unit_tests/openvpn/Makefile.am
A tests/unit_tests/openvpn/input/appears_empty.txt A tests/unit_tests/openvpn/input/empty.txt A tests/unit_tests/openvpn/input/leak_suppr.txt M tests/unit_tests/openvpn/mock_msg.c
M tests/unit_tests/openvpn/test_user_pass.c

7 files changed, 112 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/74/474/14

CMakeLists.txt +1 -1
index 9511bda..9e0b46e 100644
@@ -729,7 +729,7 @@
             add_test(${test_name} ${test_name})
             # for compat with autotools make check
             set_tests_properties(${test_name} PROPERTIES
-                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR}")
+                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR};LSAN_OPTIONS=suppressions=${_UT_SOURCE_DIR}/input/leak_suppr.txt")
         endif ()
         add_executable(${test_name}
             tests/unit_tests/openvpn/${test_name}.c
tests/unit_tests/openvpn/Makefile.am +2 -0
index 05c0ea5..50f4a11 100644
@@ -4,6 +4,8 @@
 
 AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) Unit-Tests'
 
+AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt;
+
 test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \
 	ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \
 	user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver
tests/unit_tests/openvpn/input/appears_empty.txt new file +3 -0
new file mode 100644
index 0000000..ffb749a
@@ -0,0 +1,3 @@
+
+
+(contains \t\n\t\n)
tests/unit_tests/openvpn/input/empty.txt new file +0 -0
new file mode 100644
index 0000000..e69de29
tests/unit_tests/openvpn/input/leak_suppr.txt new file +1 -0
new file mode 100644
index 0000000..72ebfe0
@@ -0,0 +1 @@
+leak:_assertions$
tests/unit_tests/openvpn/mock_msg.c +6 -2
index a2aa3f9..2cd1336 100644
@@ -41,7 +41,6 @@
 msglvl_t x_debug_level = 0; /* Default to (almost) no debugging output */
 msglvl_t print_x_debug_level = 0;
 
-bool fatal_error_triggered = false;
 
 char mock_msg_buf[MOCK_MSG_BUF];
 
@@ -75,7 +74,6 @@
 {
     if (flags & M_FATAL)
     {
-        fatal_error_triggered = true;
         printf("FATAL ERROR:");
     }
     CLEAR(mock_msg_buf);
@@ -86,6 +84,12 @@
         printf("%s", mock_msg_buf);
         printf("\n");
     }
+#ifndef NO_CMOCKA
+    if (flags & M_FATAL)
+    {
+        mock_assert(false, "FATAL ERROR", __FILE__, __LINE__);
+    }
+#endif
 }
 
 void
tests/unit_tests/openvpn/test_user_pass.c +99 -0

137 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 14
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#18 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/474?usp=email )

Change subject: test_user_pass: Check fatal errors for empty username/password
......................................................................

test_user_pass: Check fatal errors for empty username/password

Required a fix to mock_msg to make tests of M_FATAL possible at all.
This also tests some cases which arguably should throw a fatal error but do not.

v2:
- Suppress LeakSanitizer errors for fatal error tests. Due to aborting the function, the memory will not be cleaned up, but that is expected.
v3:
- Disable assert tests with MSVC. Does not seem to catch the error correctly.
- Rebase on top of parallel-tests series to get AM_TESTS_ENVIRONMENT.
v8:
- Update srcdir handling according to master.
v10:
- Update mock_msg.c fatal handling to be compatible with NO_CMOCKA.

Change-Id Icabc8acf75638c86c8c395e9ffecba7a7226cd97

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/474
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59245149/

---
M CMakeLists.txt
M tests/unit_tests/openvpn/Makefile.am
A tests/unit_tests/openvpn/input/appears_empty.txt A tests/unit_tests/openvpn/input/empty.txt A tests/unit_tests/openvpn/input/leak_suppr.txt M tests/unit_tests/openvpn/mock_msg.c
M tests/unit_tests/openvpn/test_user_pass.c

7 files changed, 112 insertions(+), 3 deletions(-)
CMakeLists.txt +1 -1
index 9511bda..9e0b46e 100644
@@ -729,7 +729,7 @@
             add_test(${test_name} ${test_name})
             # for compat with autotools make check
             set_tests_properties(${test_name} PROPERTIES
-                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR}")
+                ENVIRONMENT "srcdir=${_UT_SOURCE_DIR};LSAN_OPTIONS=suppressions=${_UT_SOURCE_DIR}/input/leak_suppr.txt")
         endif ()
         add_executable(${test_name}
             tests/unit_tests/openvpn/${test_name}.c
tests/unit_tests/openvpn/Makefile.am +2 -0
index 05c0ea5..50f4a11 100644
@@ -4,6 +4,8 @@
 
 AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) Unit-Tests'
 
+AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt;
+
 test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \
 	ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \
 	user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver
tests/unit_tests/openvpn/input/appears_empty.txt new file +3 -0
new file mode 100644
index 0000000..ffb749a
@@ -0,0 +1,3 @@
+
+
+(contains \t\n\t\n)
tests/unit_tests/openvpn/input/empty.txt new file +0 -0
new file mode 100644
index 0000000..e69de29
tests/unit_tests/openvpn/input/leak_suppr.txt new file +1 -0
new file mode 100644
index 0000000..72ebfe0
@@ -0,0 +1 @@
+leak:_assertions$
tests/unit_tests/openvpn/mock_msg.c +6 -2
index a2aa3f9..2cd1336 100644
@@ -41,7 +41,6 @@
 msglvl_t x_debug_level = 0; /* Default to (almost) no debugging output */
 msglvl_t print_x_debug_level = 0;
 
-bool fatal_error_triggered = false;
 
 char mock_msg_buf[MOCK_MSG_BUF];
 
@@ -75,7 +74,6 @@
 {
     if (flags & M_FATAL)
     {
-        fatal_error_triggered = true;
         printf("FATAL ERROR:");
     }
     CLEAR(mock_msg_buf);
@@ -86,6 +84,12 @@
         printf("%s", mock_msg_buf);
         printf("\n");
     }
+#ifndef NO_CMOCKA
+    if (flags & M_FATAL)
+    {
+        mock_assert(false, "FATAL ERROR", __FILE__, __LINE__);
+    }
+#endif
 }
 
 void
tests/unit_tests/openvpn/test_user_pass.c +99 -0

137 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/474?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icabc8acf75638c86c8c395e9ffecba7a7226cd97
Gerrit-Change-Number: 474
Gerrit-PatchSet: 14
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>